package cn.com.wangluotongxin.admin.netty;

import cn.com.wangluotongxin.admin.netty.constants.AdminNettyRabbitMqConstants;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class AdminNettyRabbitmqPushService {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    public void push(String queueName, Object data) {
        String exchangeName = AdminNettyRabbitMqConstants.ADMIN_NETTY_EXCHANGE;
        log.info("rabbitmq admin netty exchange push:exchangeName-{},queueName-{}, data-{}", exchangeName, queueName, JSONObject.toJSONString(data));
        rabbitTemplate.convertAndSend(exchangeName, queueName, data);
    }
}
